﻿@using Kovan.Library.Utils;
@using Kovan.Model.ViewModel.UserCenter;
@using Kovan.Library.Extensions;
@using Kovan.Model.Entity.UserCenter;
@using Kovan.Model.Parameter.UserCenter;
@{
    ViewBag.Title = "用户管理";
    var Items = Model as List<EUser>;
    var depts = ViewBag.Depts as List<act_dept>;
    var param = ViewBag.Param as PUser;
}
<form id="pagerForm" method="post" action="@Url.Content("~/Manage/User")">
<input type="hidden" name="PageIndex" value="@param.PageIndex" />
<input type="hidden" name="PageSize" value="@param.PageSize" />
<input type="hidden" name="keyword" value="@param.keyword" />
<input type="hidden" name="enabled" value="@param.enabled" />
<input type="hidden" name="deptId" value="@param.deptId" />
</form>
<div class="pageHeader">
    <form onsubmit="return navTabSearch(this);" action="@Url.Content("~/Manage/User")" method="post">
    <div class="searchBar">
        <input type="hidden" name="PageSize" value="@param.PageSize" />
        <table class="searchContent">
            <tr>
                <td>
                    用户姓名 / 登录名：<input type="text" name="keyword" value="@param.keyword" />
                </td>
                <td>
                    部门：
                </td>
                <td>
                    <select class="combox" name="deptId">
                        <option value="">请选择</option>
                        @foreach (var d in depts)
                        {
                            <option value="@d.dept_id" @(param.deptId == d.dept_id ? "selected" : "")>@d.name</option>
                        }
                    </select>
                </td>
                <td>
                    用户状态：
                </td>
                <td>
                    <select class="combox" name="enabled">
                        <option value="">请选择</option>
                        <option value="1"  @(param.enabled == 1 ? "selected" : "")>激活</option>
                        <option value="0" @(param.enabled == 0 ? "selected" : "")>未激活</option>
                    </select>
                </td>
            </tr>
        </table>
        <div class="subBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent">
                            <button type="submit">
                                检索</button></div>
                    </div>
                </li>
                @*<li><a class="button" href="demo_page6.html" target="dialog" mask="true" title="查询框">
                    <span>高级检索</span></a></li>*@
            </ul>
        </div>
    </div>
    </form>
</div>
<div class="pageContent">
    <div class="panelBar">
        <ul class="toolBar">
            <li><a class="add" href="@Url.Content("~/Manage/User/GetOperate")" target="dialog" rel="user_operate" mask="true" width="800" height="300" title="添加用户">
                <span>添加</span></a></li>
            <li class="line">line</li>
            <li><a class="delete" href="javascript:;" onclick="UserManage.Delete();"><span>删除</span></a></li>
            @*<li><a class="edit" href="demo_page4.html?uid={sid_user}" target="navTab"><span>修改</span></a></li>*@
            <li class="line">line</li>
            @*<li><a class="icon" href="demo/common/dwz-team.xls" target="dwzExport" targettype="navTab"
                title="实要导出这些记录吗?"><span>导出用户</span></a></li>*@
        </ul>
    </div>
    <table class="table" width="100%" layouth="138">
        <thead>
            <tr>
                <th width="3%" align="center">
                    <input type="checkbox" group="uids" class="checkboxCtrl" />
                </th>
                <th width="5%" align="center">
                    序号
                </th>
                <th width="10%" align="center">
                    用户姓名
                </th>
                <th width="10%" align="center">
                    登录名
                </th>
                <th width="10%" align="center">
                    部门
                </th>
                <th width="10%" align="center">
                    最后登录日期
                </th>
                <th width="10%" align="center">
                    创建日期
                </th>
                <th width="10%" align="center" title="状态">
                    状态
                </th>
                <th width="10%" align="center">
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
            @if (Items != null && Items.Count > 0)
            {
                for (int i = 0; i < Items.Count; i++)
                {
                    var item = Items[i];
                <tr target="user_id" rel="@item.user.user_id">
                    <td>
                        <input type="checkbox" name="uids" value="@item.user.user_id" />
                    </td>
                    <td>
                        @(i + 1)
                    </td>
                    <td>
                        @item.user.name
                    </td>
                    <td>
                        @item.user.login_name
                    </td>
                    <td>
                        @item.dept.name
                    </td>
                    <td>
                        @(item.user.last_login_date.HasValue ? Html.Raw(item.user.last_login_date.Value.ToString()) : Html.Raw("..."))
                    </td>
                    <td>
                        @(item.user.create_date.HasValue ? Html.Raw(item.user.create_date.Value.ToString()) : Html.Raw("..."))
                    </td>
                    <td>
                        @if (item.user.enabled.HasValue && item.user.enabled == 1)
                        {
                            <span class="status_true">激活</span>
                        }
                        else
                        {
                            <span class="status_false">未激活</span>
                        }
                    </td>
                    <td>
                        <a href="@(Url.Content("~/Manage/User/GetOperate?user_id=") + item.user.user_id)" target="dialog" title="编辑用户" rel="user_operate" mask="true" width="800" height="300">
                            编辑</a>@* | <a href="javascript:;">角色 </a>*@
                    </td>
                </tr>
                }
            }
        </tbody>
    </table>
    <div class="panelBar">
        <div class="pages">
            <span>显示</span>
            <select class="combox" name="PageSize" onchange="navTabPageBreak({numPerPage:this.value})">
                <option value="10" @(param.PageSize == 10 ? "selected=selected" : "")>10</option>
                <option value="20" @(param.PageSize == 20 ? "selected=selected" : "")>20</option>
                <option value="50" @(param.PageSize == 50 ? "selected=selected" : "")>50</option>
                <option value="100" @(param.PageSize == 100 ? "selected=selected" : "")>100</option>
                <option value="200" @(param.PageSize == 200 ? "selected=selected" : "")>200</option>
            </select>
            <span>条，共 @param.TotalRows 条</span>
        </div>
        <div class="pagination" targettype="navTab" totalcount="@param.TotalRows" numPerPage="@param.PageSize" pagenumshown="10"
            currentpage="@param.PageIndex">
        </div>
    </div>
</div>
<script type="text/javascript" src="@Url.Content2("~/Scripts/Manage/User/Index.js")"></script>
